<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function render(template, data){
      const reg =  /\{\{(\w+)\}\}/; 
      while(reg.test(template)){
        const key = reg.exec(template)[1]
        template = template.replace(reg,data[key])
      }
      return template
    }
    let template = '我是{{name}}，年龄{{age}}，性别{{sex}}';
    let person = {
        name: '布兰',
        age: 12
    }
    console.log(render(template, person))
  </script>
</body>
</html>